const app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        loading: app.globalData.loading,
        index: 0,
        base: !1
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        app.setAppSystem(this),
            app.userLogin(this),
            this.initData();
    },
    initData(){
        let _this = this;
        app.hyy.request({
            url: "entry/wxapp/type",
            cachetime: "0",
            success: function (res) {
                _this.setData({
                    nav: res.data,
                });

                _this.setData({loading:false});  
            }
        });
    },
    settled: function (a) {
        wx.navigateTo({
            url: "../../settled/settled",
            success: function (a) { },
            fail: function (a) { },
            complete: function (a) { }
        });
    },
    formid_one: function (a) {
        app.hyy.request({
            url: "entry/wxapp/SaveFormid",
            cachetime: "0",
            data: {
                user_id: wx.getStorageSync("users").id,
                form_id: a.detail.formId,
                openid: wx.getStorageSync("openid")
            },
            success: function (a) { }
        });
    },
    bindPickerChange: function (a) {
        var e = this, t = e.data.id, n = a.detail.value, o = e.data.nav[e.data.index].array[n];
        for (var i in e.data.nav[e.data.index].array) if (o == e.data.nav[e.data.index].arrays[i].name) var d = e.data.nav[e.data.index].arrays[i].id, s = e.data.nav[e.data.index].arrays[i].type_id, r = e.data.nav[e.data.index].money;
        wx.navigateTo({
            url: "../tiezi/add?info=" + o + "&id=" + t + "&type_id=" + d + "&money=" + r + "&type2_id=" + s
        });
    },
    edit: function (a) {
        this.setData({loading:true});
        var e = this;
        var t = a.currentTarget.dataset.index, n = a.currentTarget.dataset.id, o = e.data.nav[t].money + "," + e.data.nav[t].money2, i = [], d = wx.getStorageSync("users").id;
        app.hyy.request({
            url: "entry/wxapp/FtXz",
            cachetime: "0",
            data: {
                user_id: d
            },
            success: function (a) {
                "今天发帖次数已经超限!" == a.data ? wx.showModal({
                    title: "提示",
                    content: "今天发帖次数已经超限!"
                }) : app.hyy.request({
                    url: "entry/wxapp/type2",
                    cachetime: "0",
                    data: {
                        id: n
                    },
                    success: function (a) {
                        0 != a.data.length ? (a.data.map(function (a) {
                            var e;
                            e = a.name, i.push(e);
                        }), e.setData({
                            array: i,
                            arrays: a.data,
                            base: !0,
                            type_id: n,
                            money: o
                        })) : wx.navigateTo({
                            url: "../tiezi/add?id=" + e.data.id + "&type_id=" + n + "&money=" + o + "&type2_id=0"
                        });
                        e.setData({ loading: false });
                    }
                });
                
            }
        });
    },
    cancel: function (a) {
        this.setData({
            base: !1
        });
    },
    selected: function (a) {
        var e = this, t = e.data.arrays, n = a.currentTarget.id, o = e.data.type_id, i = t[n].id, d = t[n].name, s = e.data.money;
        e.setData({
            base: !1
        }), wx.navigateTo({
            url: "../tiezi/add?type2_id=" + i + "&type_id=" + o + "&money=" + s + "&info=" + d
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})